package com.dmpp.mes.controller;


import com.dmpp.mes.bean.ResponseData;
import com.dmpp.mes.parameterInfo.Process;
import com.dmpp.mes.parameterInfo.Product;
import com.dmpp.mes.service.ProcessService;
import com.dmpp.mes.service.ProductService;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@CrossOrigin
@RestController
@RequestMapping("Product")
public class ProductController {
//成品编码
    @Autowired
    private ProductService service;


    @RequestMapping(value = "/FindAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findAll(Integer page, Integer pageSize,Product product) {
        PageHelper.startPage(page, pageSize);
        return service.findAll(product);
    }

//    @RequestMapping(value = "/FindByCode", method = RequestMethod.POST)
//    @ResponseBody
//    public ResponseData findByCode(String code) {
//        return service.findByCode(code);
//    }

    @RequestMapping(value = "/FindById", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData findByCode(String id) {
        return service.findById(id);
    }

    @RequestMapping(value = "/UpdateById", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData updateById(Product product) {
        return service.updateById(product);
    }

    @RequestMapping(value = "/Insert", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData insert(Product product) {
        return service.insert(product);
    }

//    @RequestMapping(value = "/Delete", method = RequestMethod.POST)
//    @ResponseBody
//    public ResponseData delete(String code) {
//        return service.delete(code);
//    }

    @RequestMapping(value = "/DeleteById", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData deleteById(String id) {
        return service.deleteById(id);
    }

    @RequestMapping(value = "/Altogether", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData altogether(Product product) {
        return service.altogether(product);
    }

    @RequestMapping(value = "/SemiFindAll", method = RequestMethod.POST)
    @ResponseBody
    public ResponseData semiFindAll(Integer page, Integer pageSize,Product product) {
        PageHelper.startPage(page, pageSize);
        return service.semiFindAll(product);
    }

}
